<template>
  <dw-tree ref="dictTreeRef" :getTreeUrl="getTreeUrl" :addTreeUrl="addTreeUrl" :editTreeUrl="editTreeUrl" :delTreeUrl="delTreeUrl" :treeProps="treeProps" @currentChange="currentNodeChange"></dw-tree>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue';
import type { IDict } from '../dict';

defineOptions({
  name: 'DictTree',
});
const dictTreeRef = ref();
const getTreeUrl: string = '/admin-api/sys/dict/list';
const addTreeUrl: string = '/admin-api/sys/dict';
const editTreeUrl: string = '/admin-api/sys/dict';
const delTreeUrl: string = '/admin-api/sys/dict/{id}';
const treeProps = { label: 'dictName', code: 'dictCode', children: 'children', total: 'totalNum' };
const currentNodeData = ref<IDict | undefined>();
const emits = defineEmits(['currentNodeChange']);
const currentNodeChange = (data: IDict) => {
  currentNodeData.value = data;
};
watch(currentNodeData, () => {
  emits('currentNodeChange', currentNodeData.value);
});
</script>
